package com.xx.ViewInfo;

import javafx.collections.ListChangeListener;
import javafx.scene.control.Tab;
import javafx.scene.control.TabPane;

public class FileViewBar extends TabPane {
    public FileViewBar() {
        setVisible(false);
        setMinSize(0, 0);
        setTabClosingPolicy(TabClosingPolicy.UNAVAILABLE);
        getTabs().addListener((ListChangeListener<? super Tab>) event -> setVisible(event.getList().size() != 0));
    }

    public void setChoiceItem(FileViewItem choiceItem) {
        getSelectionModel().select(choiceItem);
    }

    public void addItem(FileViewItem fileViewItem) {
        getTabs().add(0, fileViewItem);
        setChoiceItem(fileViewItem);
    }
}
